package week8;

public class HeapQueueObject<T>  implements Comparable<HeapQueueObject>{
    private static int nextOrder = 0;
    private int arrivalOrder;
    private T element;


    public HeapQueueObject(T element)
    {
        this.element = element;
        arrivalOrder = nextOrder;
        nextOrder++;
    }

    // 返回元素
    public T getElement()
    {
        return element;
    }

    // 返回该节点的到达顺序。
    public int getArrivalOrder()
    {
        return arrivalOrder;
    }

    // 返回此节点的字符串表示形式。
    public String toString()
    {
        return (element + "  " );
    }

    public int compareTo(HeapQueueObject obj)
    {
        int result;

       if (arrivalOrder > obj.getArrivalOrder())
            result = 1;
        else
            result = -1;

        return result;
    }
}
